package com.iyoudoock.citymine.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;

import com.iyoudoock.citymine.BaseActivity;
import com.iyoudoock.citymine.R;
import com.sqm.sharelib.ShareUtils;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.media.UMImage;
import com.umeng.socialize.media.UMVideo;
import com.umeng.socialize.media.UMWeb;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ShareActivity extends BaseActivity {

    @BindView(R.id.wx_friend_container)
    LinearLayout wxFriendContainer;
    @BindView(R.id.wx_circle_container)
    LinearLayout wxCircleContainer;
    @BindView(R.id.qq_friend_container)
    LinearLayout qqFriendContainer;
    @BindView(R.id.qzone_container)
    LinearLayout qzoneContainer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_share);
        ButterKnife.bind(this);
    }

    @Override
    public void initNav() {
        super.initNav();
        setTitle("分享有礼");
    }

    @Override
    public void init() {
        initShare();
        wxFriendContainer.setOnClickListener(this);
        wxCircleContainer.setOnClickListener(this);
        qqFriendContainer.setOnClickListener(this);
        qzoneContainer.setOnClickListener(this);
    }

    /**
     * init share
     */
    private void initShare() {
        String title = "拾起卖";
        String content = "废品分类回收，垃圾源头减量";
        String targetUrl = "http://a.app.qq.com/o/simple.jsp?pkgname=com.iyoudoock.citymine";

        UMImage image = new UMImage(this, R.mipmap.share_icon);
        image.mText = "拾起卖";

        UMWeb umWeb = new UMWeb(targetUrl);
        umWeb.setTitle(title);
        umWeb.setDescription(content);
        umWeb.setThumb(image);


        ShareUtils.initContent(this, content, umWeb);

    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.wx_friend_container:
                ShareUtils.share(SHARE_MEDIA.WEIXIN);
                break;
            case R.id.wx_circle_container:
                ShareUtils.share(SHARE_MEDIA.WEIXIN_CIRCLE);
                break;
            case R.id.qq_friend_container:
                ShareUtils.share(SHARE_MEDIA.QQ);
                break;
            case R.id.qzone_container:
                ShareUtils.share(SHARE_MEDIA.QZONE);
                break;
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        ShareUtils.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ShareUtils.release();
    }
}
